﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEditor;
using UnityEditor.UI;

[CustomEditor(typeof(AnimatorButton))]
public class AnimatorButtonEditor : ButtonEditor
{
    private SerializedProperty animatorButtonProperty;
    private SerializedProperty NormalProperty;
    private SerializedProperty MouseUpProperty;
    private SerializedProperty MouseDownProperty;
    private SerializedProperty MouseEnterProperty;

    protected override void OnEnable()
    {
        base.OnEnable();
        //component = this.target as AnimatorButton;
        animatorButtonProperty = serializedObject.FindProperty("animatorButton");
        NormalProperty = serializedObject.FindProperty("Normal");
        MouseUpProperty = serializedObject.FindProperty("MouseUp");
        MouseDownProperty = serializedObject.FindProperty("MouseDown");
        MouseEnterProperty = serializedObject.FindProperty("MouseEnter");


    }

    public override void OnInspectorGUI()
    {

        EditorGUILayout.PropertyField(animatorButtonProperty);//属性字段

        //component.Normal = EditorGUILayout.TextField("Normal", component.Normal);
        //component.MouseUp = EditorGUILayout.TextField("MouseUp", component.MouseUp);
        //component.MouseDown = EditorGUILayout.TextField("MouseDown", component.MouseDown);
        //component.MouseEnter = EditorGUILayout.TextField("MouseEnter", component.MouseEnter);

        EditorGUILayout.PropertyField(NormalProperty);
        EditorGUILayout.PropertyField(MouseUpProperty);
        EditorGUILayout.PropertyField(MouseDownProperty);
        EditorGUILayout.PropertyField(MouseEnterProperty);
        serializedObject.ApplyModifiedProperties();//应用修改的属性，这个不写就失效，很神奇

        base.OnInspectorGUI();
    }
}

